1
|
|
|
/** |
2
|
|
|
* 2007-2017 PrestaShop |
3
|
|
|
* |
4
|
|
|
* NOTICE OF LICENSE |
5
|
|
|
* |
6
|
|
|
* This source file is subject to the Academic Free License (AFL 3.0) |
7
|
|
|
* that is bundled with this package in the file LICENSE.txt. |
8
|
|
|
* It is also available through the world-wide-web at this URL: |
9
|
|
|
* http://opensource.org/licenses/afl-3.0.php |
10
|
|
|
* If you did not receive a copy of the license and are unable to |
11
|
|
|
* obtain it through the world-wide-web, please send an email |
12
|
|
|
* to [email protected] so we can send you a copy immediately. |
13
|
|
|
* |
14
|
|
|
* DISCLAIMER |
15
|
|
|
* |
16
|
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer |
17
|
|
|
* versions in the future. If you wish to customize PrestaShop for your |
18
|
|
|
* needs please refer to http://www.prestashop.com for more information. |
19
|
|
|
* |
20
|
|
|
* @author PrestaShop SA <[email protected]> |
21
|
|
|
* @copyright 2007-2017 PrestaShop SA |
22
|
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) |
23
|
|
|
* International Registered Trademark & Property of PrestaShop SA |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
function fill_the_form(){ |
27
|
|
|
firstname_input = document.getElementsByName("payment_address[firstname]"); |
|
|
|
|
28
|
|
|
billing_firstname = ''; |
|
|
|
|
29
|
|
|
if (firstname_input.length > 0){ |
30
|
|
|
billing_firstname = firstname_input[0].value; |
31
|
|
|
} |
32
|
|
|
billing_lastname = ''; |
|
|
|
|
33
|
|
|
lastname_input = document.getElementsByName("payment_address[lastname]"); |
|
|
|
|
34
|
|
|
if (lastname_input.length > 0){ |
35
|
|
|
billing_lastname = lastname_input[0].value; |
36
|
|
|
} |
37
|
|
|
shipping_firstname = ''; |
|
|
|
|
38
|
|
|
firstname_input = document.getElementsByName("shipping_address[firstname]"); |
39
|
|
|
if (firstname_input.length > 0){ |
40
|
|
|
shipping_firstname = firstname_input[0].value; |
41
|
|
|
} |
42
|
|
|
shipping_lastname = ''; |
|
|
|
|
43
|
|
|
lastname_input = document.getElementsByName("shipping_address[lastname]"); |
44
|
|
|
if (lastname_input.length > 0){ |
45
|
|
|
shipping_lastname = lastname_input[0].value; |
46
|
|
|
} |
47
|
|
|
email = ''; |
|
|
|
|
48
|
|
|
email_input = document.getElementsByName("supercheckout_email"); |
|
|
|
|
49
|
|
|
if (email_input.length > 0){ |
50
|
|
|
email = email_input[0].value; |
51
|
|
|
} |
52
|
|
|
billing_name = billing_firstname + " " + billing_lastname; |
|
|
|
|
53
|
|
|
shipping_name = shipping_firstname + " " + shipping_lastname; |
|
|
|
|
54
|
|
|
if (document.getElementById("paylater_full_name").value.trim() == '') { |
55
|
|
|
if (billing_name.trim() != '') { |
56
|
|
|
document.getElementById("paylater_full_name").value = billing_name; |
57
|
|
|
} else if (shipping_name.trim() != '') { |
58
|
|
|
document.getElementById("paylater_full_name").value = shipping_name; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
if (document.getElementById("paylater_email").value.trim() == '') { |
62
|
|
|
document.getElementById("paylater_email").value = email; |
63
|
|
|
} |
64
|
|
|
dni = ''; |
|
|
|
|
65
|
|
|
dni_input = document.getElementsByName("shipping_address[dni]"); |
|
|
|
|
66
|
|
|
if (dni_input.length > 0){ |
67
|
|
|
dni = dni_input[0].value; |
68
|
|
|
} |
69
|
|
|
if (document.getElementById("paylater_full_name") == document.getElementsByName("shipping[full_name]")[0].value ) { |
70
|
|
|
if (document.getElementById("paylater_dni").value.trim() != '') { |
71
|
|
|
document.getElementById("paylater_dni").value = dni; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
saddress1 = document.getElementsByName("shipping_address[address1]"); |
|
|
|
|
75
|
|
|
saddress2 = document.getElementsByName("shipping_address[address2]"); |
|
|
|
|
76
|
|
|
sa1 = ''; |
|
|
|
|
77
|
|
|
sa2 = ''; |
|
|
|
|
78
|
|
|
if (saddress1.length > 0){ |
79
|
|
|
sa1 = saddress1[0].value; |
80
|
|
|
} |
81
|
|
|
if (saddress2.length > 0){ |
82
|
|
|
sa2 = saddress2[0].value; |
83
|
|
|
} |
84
|
|
|
saddress = sa1 + " " + sa1; |
|
|
|
|
85
|
|
|
|
86
|
|
|
address1 = document.getElementsByName("payment_address[address1]"); |
|
|
|
|
87
|
|
|
address2 = document.getElementsByName("payment_address[address2]"); |
|
|
|
|
88
|
|
|
a1 = ''; |
|
|
|
|
89
|
|
|
a2 = ''; |
|
|
|
|
90
|
|
|
if (address1.length > 0){ |
91
|
|
|
a1 = address1[0].value; |
92
|
|
|
} |
93
|
|
|
if (address2.length > 0){ |
94
|
|
|
a2 = address2[0].value; |
95
|
|
|
} |
96
|
|
|
address = sa1 + " " + sa1; |
|
|
|
|
97
|
|
|
if (document.getElementsByName("shipping[full_name]")[0].value.trim() == '') { |
98
|
|
|
document.getElementsByName("shipping[full_name]")[0].value = saddress; |
99
|
|
|
} |
100
|
|
|
if (document.getElementsByName("billing[full_name]")[0].value.trim() == '') { |
101
|
|
|
document.getElementsByName("billing[full_name]")[0].value = address; |
102
|
|
|
} |
103
|
|
|
dob_1 = document.getElementsByName("customer_personal[dob_days]"); |
|
|
|
|
104
|
|
|
dob_2 = document.getElementsByName("customer_personal[dob_months]"); |
|
|
|
|
105
|
|
|
dob_3 = document.getElementsByName("customer_personal[dob_years]"); |
|
|
|
|
106
|
|
|
if (dob_1.length > 0 && dob_2.length > 0 && dob_3.length > 0){ |
107
|
|
|
if (document.getElementById("paylater_dob").value.trim() == '') { |
108
|
|
|
document.getElementById("paylater_dob").value = dob_3[0].value + "-" + dob_2[0].value + "-" + dob_1[0].value; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
function check_pagantis_ready(){ |
113
|
|
|
if (document.getElementById("paylater_email").value.trim() != '' && |
114
|
|
|
document.getElementById("paylater_full_name").value.trim() != '') { |
115
|
|
|
if ($('input:radio[id=paylater]').is(":checked")){ |
116
|
|
|
if ($(".permanent-warning").size() <= 0) { |
117
|
|
|
$('#paylater_form').submit(); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
$(document).on("click", function(){ |
123
|
|
|
fill_the_form(); |
124
|
|
|
}); |
125
|
|
|
|
126
|
|
|
$("#supercheckout_confirm_order").on("click", function(){ |
127
|
|
|
fill_the_form(); |
128
|
|
|
setTimeout(function(){ |
129
|
|
|
check_pagantis_ready(); |
130
|
|
|
}, 1500); |
131
|
|
|
|
132
|
|
|
}); |
133
|
|
|
|